package LeetCode.LeetCode2;

/**
 * 扑克牌中的顺子
 * @author lumin
 * @date 2022/03/16 11:50
 **/
public class Num61 {
    public static boolean isStraight(int[] nums) {
        int num0 = 0;
        int maxNum = -1;
        int minNum = 20;
        for (int i = 0; i < nums.length; i++) {
            if(nums[i] == 0){
                num0++;
                continue;
            }
            if(nums[i] == maxNum || nums[i] == minNum){
                return false;
            }
            if(nums[i] > maxNum){
                maxNum = nums[i];
            }else if(nums[i] < minNum){
                minNum = nums[i];
            }
        }
        if(maxNum - minNum <= 5){
            return true;
        }else{
            return false;
        }
    }

    public static void main(String[] args) {
        int[] nums = {1,2,3,4,5};
        System.out.println(isStraight(nums));
    }
}